package com.data.util;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;

/**
 * 图片响应
 *
 * @author:HingLo
 * @create 2017-09-28 17:13
 **/
public class ImageLookUtils {

    public static void responseImage(byte[] inputStream, HttpServletResponse response) {
        try {
            response.setContentType("image/png");
            OutputStream stream = response.getOutputStream();
            stream.write(inputStream);
            stream.flush();
            stream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据软件的id 与图片的名称来读取图片
     *
     * @param id
     * @param name
     * @return
     */
    public static byte[] lookImageNameUtils(String id, String name) {
        if (CheckDataUtils.stringUtils(name) && CheckDataUtils.stringUtilsID(id)) {
            name = name.trim();
            id = id.trim();
            return FileResumeUtils.readMinIcon(id, name);
        }

        return FileResumeUtils.readMinIcon("default", "default.png");
    }

}

